/*************************************************
Author: byron
Date: 12/20/2012
Description:
Notes: 
*************************************************/

#ifndef __CSceneCfg_h__
#define __CSceneCfg_h__

#include "commclass.h"
#include "CTArray.h"
#include "CTHashObjectMgr.h"

class CSceneCfgData
{
public:
    CSceneCfgData() 
    {
        Clear();
    }

    void Clear()
    {
        _shResID = 0;
        _uiMapID = 0;
        _iEnterX = 0;
        _iEnterY = 0;
        _iDeadBorderX = 0;
        _iDeadBorderY = 0;
        _uiMonGroupID = 0;
        _uiLeftGroupID = 0;
        _uiRightGroupID = 0;
        _iMonsterInitX = 0;
        _iMonsterInitY = 0;
        _uiRelayMapID = 0;
        _uiAuxRelayMapID = 0;
    }

    virtual ~CSceneCfgData() 
    {
    }

    bool IsValidID() const {return _shResID > 0;}

    int GetResID() const {return _shResID;}
    unsigned int GetMapID() const {return _uiMapID;}
    int GetEnterX() const {return _iEnterX;}
    int GetEnterY() const {return _iEnterY;}
    int GetDeadBorderX() const {return _iDeadBorderX;}
    int GetDeadBorderY() const {return _iDeadBorderY;}
    unsigned int GetMonGroupID() const {return _uiMonGroupID;}
    unsigned int GetLeftGroupID() const {return _uiLeftGroupID;}
    unsigned int GetRightGroupID() const {return _uiRightGroupID;}
    int GetMonsterInitX() const {return _iMonsterInitX;}
    int GetMonsterInitY() const {return _iMonsterInitY;}
    unsigned int GetRelayMapID() const {return _uiRelayMapID;}
    unsigned int GetAuxRelayMapID() const {return _uiAuxRelayMapID;}

    void SetResID(short shResID){_shResID = shResID;}
    void SetMapID(unsigned int uiMapID){_uiMapID = uiMapID;}
    void SetEnterX(int iEnterX){_iEnterX = iEnterX;}
    void SetEnterY(int iEnterY){_iEnterY = iEnterY;}
    void SetDeadBorderX(int iDeadBorderX){_iDeadBorderX = iDeadBorderX;}
    void SetDeadBorderY(int iDeadBorderY){_iDeadBorderY = iDeadBorderY;}
    void SetMonGroupID(unsigned int uiGroupID){_uiMonGroupID = uiGroupID;}
    void SetLeftGroupID(unsigned int uiGroupID){_uiLeftGroupID = uiGroupID;}
    void SetRightGroupID(unsigned int uiGroupID){_uiRightGroupID = uiGroupID;}
    void SetMonsterInitX(int iMonsterInitX){_iMonsterInitX = iMonsterInitX;}
    void SetMonsterInitY(int iMonsterInitY){_iMonsterInitY = iMonsterInitY;}
    void SetRelayMapID(unsigned int uiVal){_uiRelayMapID = uiVal;}
    void SetAuxRelayMapID(unsigned int uiVal){_uiAuxRelayMapID = uiVal;}

private:
    short               _shResID;           //配置ID
    int                 _iEnterX;           //地图进入时x坐标
    int                 _iEnterY;           //地图进入时y坐标
    int                 _iDeadBorderX;      //死亡区x边界
    int                 _iDeadBorderY;      //死亡区y边界
    unsigned int        _uiMonGroupID;      //怪物组ID
    unsigned int        _uiLeftGroupID;     //左怪物组ID
    unsigned int        _uiRightGroupID;    //右怪物组ID
    unsigned int        _uiMapID;           //地图ID
    int                 _iMonsterInitX;     //怪物组初始x坐标
    int                 _iMonsterInitY;     //怪物组初始y坐标
    unsigned int        _uiRelayMapID;      //透传战斗地图ID
    unsigned int        _uiAuxRelayMapID;   //透传战斗地图ID
};

class CSceneCfg
{
public:
    typedef CTLib::CTHashObjectMgr<short, CSceneCfgData> T_SCENE_CFG_HASH;

    CSceneCfg() 
    {
    }

    virtual ~CSceneCfg() 
    {
    }

    static int CountSize()
    {
        return T_SCENE_CFG_HASH::CountSize(MAX_SCENE_CONFIG_COUNT);
    }

    int Init(const char* sBuff)
    {
        return _stSceneCfgHash.Init(sBuff, MAX_SCENE_CONFIG_COUNT);
    }

    int AddConfig(CSceneCfgData& stCfgData);

    int FindConfig(short shResID);

    CSceneCfgData& GetConfig(int iIndex);

private:
     T_SCENE_CFG_HASH _stSceneCfgHash;
};

#endif // __CSceneCfg_h__

